package com.dreem.principle.inversion;

/**
 * @program: DesignParrtern
 * @description:
 * @author: Peng
 * @create: 2021-01-16  10:31
 **/
public class DependencyInversion02 {
    public static void main(String[] args){
        new Person02().receive(new Email02());
        new Person02().receive(new WeiXin());
    }
}

interface IReceiver{
    public String getInfo();
}

class Email02 implements IReceiver {

    @Override
    public String getInfo() {
        return "Email发送的信息：hello，world！";
    }
}

class WeiXin implements IReceiver {

    @Override
    public String getInfo() {
        return "WeiXin发送的信息：hello，world！";
    }
}

class Person02{
    // 这里我们是对接口的依赖
    public void receive(IReceiver receiver){
        System.out.println(receiver.getInfo());
    }
}